#include<bits/stdc++.h>
using namespace std;
int a[101][101],b[10001],c[10001];

bool cmp(int x,int y){
    return x > y;
}
int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> a[i][j];
            b[++cnt] = a[i][j];
        }
    }
    sort(b + 1,b + 1 + cnt, cmp);
    int id = 0;
    for(int i = 1; i <= cnt; i++){
        if(b[i - 1] != b[i]){  // 去重
            id = i;  // 名次等于当前索引位置
        }
        c[b[i]] = id; 
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cout << c[a[i][j]] << " ";
        }
        cout << endl;
    }

    return 0;
}

/*
3
5 50 65
70 80 90
90 95 100
b:   100 95 90 90 80 70 65 50  5
c:    1  2   3  3  5  6  7  8  9

*/